package com.iflytek.sbd.controller;

import com.iflytek.sbd.po.Cache;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: sbd
 * @description: 登录
 * @author: 陈英俊
 * @create: 2022-01-10 10:08
 */
@Api(tags = "登录测试demo--废弃")
@Controller
@RequestMapping("/login")
public class LoginController {


    @Autowired
    private Cache cache;

//    @Value("${login.username}")
//    private String name;
//
//    @Value("${login.password}")
//    private String pwd;


    @PostMapping("/login")
    public String login(String username, String password) {
        // 此处校验用户名+密码,查出用户信息,可以封装进redis
        // 返回token
//        if (name.equals(username) && pwd.equals(password)) {
//            if (cache.getMap().containsKey(username)) {
//            } else {
//                Map<String, String> map = new HashMap<>();
//                map.put(username, password);
//                cache.setMap(map);
//            }
//            return "index";
//        } else {
//            return "login";
//        }
        return "";
    }
}
